package cn.fuck;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;

class Person {
    private String sex;
    private int age;

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof Person)) {
            return false;
        }
        if (obj == this) {
            System.out.println("==");
            return true;
        }
        Person other = (Person) obj;
        return new EqualsBuilder().
                append(age, other.age).
                append(sex, other.sex).
                isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder(21, 31).
                append(sex).
                append(age).
                toHashCode();
    }
}
public class TestApacheLang3 {
    public static void main(String[] args) {
        Person p1 = new Person();
        p1.setAge(55);
        p1.setSex("");
        Person p2 = new Person();
        p2.setAge(55);
        p2.setSex("");
        System.out.println(p1.equals(p2));
        System.out.println(p1 == p2);
    }
}
